package com.lds.erp.gateway.filter;

import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author hongsir
 * @apiNote 注册过滤器
 * @date 2018/11/9 2:06 PM
 */
@Configuration
public class RegisterFilter {

    @Bean
    public FilterRegistrationBean crossFilter() {
        FilterRegistrationBean registration = new FilterRegistrationBean();
        registration.setFilter(new FilterCross());
        registration.addUrlPatterns("/api/*");
        registration.setOrder(1);
        return registration;
    }

    @Bean
    public FilterRegistrationBean tokenFilter() {
        FilterRegistrationBean registration = new FilterRegistrationBean();
        registration.setFilter(new FilterToken());
        registration.addUrlPatterns("/api/*");
        registration.setOrder(2);
        return registration;
    }
}
